2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_SnapGridPainter.h"
30 //==============================================================================
31 SnapGridPainter::SnapGridPainter()
38 SnapGridPainter::~SnapGridPainter()
42 bool SnapGridPainter::updateFromDesign (JucerDocument
& design
)
44 if (snapGridSize
!= design
.getSnappingGridSize()
45 || snapShown
!= (design
.isSnapShown() && design
.isSnapActive (false)))
47 snapGridSize
= design
.getSnappingGridSize();
48 snapShown
= design
.isSnapShown() && design
.isSnapActive (false);
50 backgroundFill
= Image();
57 void SnapGridPainter::updateColour()
59 backgroundFill
= Image();
62 void SnapGridPainter::draw (Graphics
& g
, PaintRoutine
* backgroundGraphics
)
64 if (backgroundFill
.isNull() && snapShown
)
66 backgroundFill
= Image (Image::ARGB
, snapGridSize
, snapGridSize
, true);
68 Graphics
g (backgroundFill
);
70 Colour
col (Colours::black
);
72 if (backgroundGraphics
!= 0)
73 col
= backgroundGraphics
->getBackgroundColour().contrasting();
77 g
.setColour (col
.withAlpha (0.1f
));
78 g
.drawRect (0, 0, snapGridSize
+ 1, snapGridSize
+ 1);
81 g
.setColour (col
.withAlpha (0.35f
));
85 if (backgroundFill
.isValid())
87 g
.setTiledImageFill (backgroundFill
, 0, 0, 1.0f
);